
public class MoveEvenNumbersToTop {
	
	public static void moveEvenNumbersToTop(int [] iArr) {

		int i, j , temp;

		for (i = 0;  i < iArr.length;  i++) {
			if (iArr[i] % 2 == 1) {
				for (j = i+1;  j < iArr.length;  j++) {
					if (iArr[j] % 2 == 0) {
						temp = iArr[i];
						iArr[i] = iArr[j];
						iArr[j] = temp;
						break;
		             }
		         }
		     }
		}
	}
		
	public static void main(String args[]) {
		
		int iArr[] = {2, 1, 9, 6, 4, 8, 55, 77, 41, 0, 4};
		
		System.out.println("Original array");
	    for (int number : iArr) {
	      System.out.print(number+" ");
	    }

	    moveEvenNumbersToTop(iArr);
	    System.out.println("\nArray After processed");     
		for (int number : iArr) {
		      System.out.print(number+" ");
		}
	}
}
/* Result
Original array
2 1 9 6 4 8 55 77 41 0 4 
Array After processed
2 6 4 8 0 4 55 77 41 9 1 
 */
